# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=twine
pkgver=3.8.0
pkgrel=1
pkgdesc="Collection of utilities for publishing packages on PyPI"
url="https://twine.readthedocs.io/en/latest/"
# ppc64le blocked by py3-importlib-metadata
arch="noarch !ppc64le"
license="Apache-2.0"
depends="
	py3-colorama
	py3-importlib-metadata
	py3-keyring
	py3-pkginfo
	py3-readme_renderer
	py3-requests-toolbelt
	py3-requests>=2.20.0
	py3-rfc3986
	py3-setuptools
	py3-tqdm
	python3
	"
makedepends="
	py3-build
	py3-installer
	py3-setuptools_scm
	py3-wheel
	"
checkdepends="
	py3-jaraco.envs
	py3-munch
	py3-portend
	py3-pretend
	py3-pytest
	py3-pytest-cov
	py3-pytest-socket
	"
source="https://files.pythonhosted.org/packages/source/t/twine/twine-$pkgver.tar.gz
	0001-remove-setuptools-scm.patch
	"

# Backwards compatibility
provides="py3-$pkgname=$pkgver-r$pkgrel"
replaces="py3-$pkgname"

build() {
	python3 -m build --no-isolation --skip-dependency-check --wheel
}

check() {
	# deselect'ed tests require a network connection
	PYTHONPATH="$PWD/build/lib" pytest \
		--deselect tests/test_integration.py \
		--deselect tests/test_upload.py::test_check_status_code_for_wrong_repo_url \
		-k "not test_metadata_dictionary_keys and not test_fips_metadata_excludes_md5_and_blake2 and not test_pkginfo_returns_no_metadata and not test_pkginfo_returns_no_metadata"
}

package() {
	python3 -m installer -d "$pkgdir" dist/twine-$pkgver-py3-none-any.whl
}

sha512sums="
bc825aa723b2c023fcaa0ffc2e5ff8258256f0b90e0fd001f7d6e5e72f82686d0d3286ed106ea99cf5cca6b656540c37f1e18857704e86d014135ed2fecbe866  twine-3.8.0.tar.gz
1db21fed53409a2c3421b76708b4df6a0eeb2f9068bc3c83d03eca491bc2475a3db14251596df7a5adfe111032cbef27340d71eb34b38e374e9fa085e4f6285b  0001-remove-setuptools-scm.patch
"
